<template>
	<view>
		<view class="content">
			<view class="row">
				<view class="nominal">
					账号
				</view>
				<view class="input">
					<input placeholder="请输入账号" type="text" v-model="account" />
				</view>
			</view>
			
			<view class="row">
				<view class="nominal">
					旧密码
				</view>
				<view class="input">
					<input placeholder="请输入旧密码" type="text" v-model="old_password" />
				</view>
			</view>
			
			<view class="row">
				<view class="nominal">
					新密码
				</view>
				<view class="input">
					<input placeholder="请输入新密码" type="text" v-model="new_password" />
				</view>
			</view>
			
			<view class="row">
				<view class="nominal">
					确认密码
				</view>
				<view class="input">
					<input placeholder="请输入确认密码" type="text" v-model="confirm_password" />
				</view>
			</view>

		</view>
		<view class="save" @tap="save">
			<view class="btn">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: '',
				old_password: '',
				new_password: '',
				confirm_password:''
			};
		},
		onShow() {
			
		},
		methods: {
			save() {
				if (!this.account) {
					uni.showToast({
						title: '请输入账号',
						icon: 'none'
					});
					return false;
				}
				if (!this.old_password) {
					uni.showToast({
						title: '请输入旧密码',
						icon: 'none'
					});
					return false;
				}
				if (!this.new_password) {
					uni.showToast({
						title: '请输入新密码',
						icon: 'none'
					});
					return false;
				}
				if (!this.confirm_password) {
					uni.showToast({
						title: '请输入确认密码',
						icon: 'none'
					});
					return false;
				}
				this.$api.http.post('change-password', {
					account: this.account,
					old_password: this.old_password,
					new_password:this.new_password,
					confirm_password:this.confirm_password
				}).then(res => {
					if (res) {
						if (res.code === 1) {
							this.$api.msg("保存成功")
							setTimeout(() => {
								uni.navigateBack();
							}, 1000)
						}
					}
				})
			}
		}
	};
</script>
<style lang="scss">
	page {
		background: #fff;
	}

	.save {
		view {
			display: flex;
		}

		position: fixed;
		bottom: 30rpx;
		width: 100%;
		height: 120upx;
		display: flex;
		justify-content: center;
		align-items: center;

		.btn {
			width: 90%;
			height: 100upx;
			border-radius: 100upx;
			background: #3cbdc5;
			color: #fff;
			justify-content: center;
			align-items: center;
			font-size: 30upx;
		}
	}

	.content {
		display: flex;
		flex-wrap: wrap;

		.row {
			width: 94%;
			padding: 0 3%;

			.nominal {
				width: 100%;
				font-weight: bold;
				font-size: 28upx;
				align-items: center;
				margin-top: 50rpx;
			}

			.input {
				width: 100%;
				padding: 20upx 0;
				align-items: center;
				font-size: 28upx;
				margin-top: 30rpx;
				border-bottom: 1px solid #eee;

				input {
					font-size: 28upx;
				}

				&.switch {
					justify-content: flex-end;
				}

				.textarea {
					margin: 20upx 0;
					min-height: 120upx;
				}
			}
		}
	}
</style>
